import type { RouteRecordRaw } from "vue-router";
import login from "@/views/login/index.vue";
import admin from "@/views/admin/index.vue";

// 让其自动导入设置的路由文件
// eager —— 设置为 true ,表示同步
const files = import.meta.glob("./routes/*.ts", { eager: true });
const children = [] as RouteRecordRaw[]
for(let key in files){
  let value = (files[key as keyof typeof files] as any ).default 
  if(Array.isArray(value)){
    children.push(...value)
  }else{
     children.push(value)
  } 
}

 
    
export default [
  {
    path: "/login", 
    name: "login",
    component: login,
    //路由守卫查看是否登录
    meta: {
      nologin: true,
    },
  },
  {
    path: "/",
    name: "admin",
    component: admin,
    redirect:'/dashboard',
    children,
  },
] as RouteRecordRaw[];
